#include <iostream>
#include <cstring>
#include <cstdio>

int main() {
    // 一维数组的声明与打印
    int arr1[5] = {1, 2, 3, 4, 5};
    for(int i = 0; i < 5; i++) {
        std::cout << "arr1[" << i << "] = " << arr1[i] << std::endl;
    }

    // 二维数组的声明与打印
    int arr2[2][3] = {{1, 2, 3}, {4, 5, 6}};
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 3; j++) {
            std::cout << "arr2[" << i << "][" << j << "] = " << arr2[i][j] << std::endl;
        }
    }

    // memset函数
    int arr3[5];
    std::memset(arr3, 0, sizeof(arr3));
    for(int i = 0; i < 5; i++) {
        std::cout << "arr3[" << i << "] = " << arr3[i] << std::endl;
    }

    // 字符数组的初始化，输入和输出
    char str[100];
    std::cout << "Enter a string: ";
    std::cin.getline(str, 100);
    std::cout << "You entered: " << str << std::endl;

    // string.h头文件的strlen、strcmp、strcpy和strcat函数的用法
    char str1[100] = "Hello";
    char str2[100] = "World";
    char str3[100];
    std::cout << "strlen(str1) = " << std::strlen(str1) << std::endl;
    std::cout << "strcmp(str1, str2) = " << std::strcmp(str1, str2) << std::endl;
    std::strcpy(str3, str1);
    std::cout << "strcpy(str3, str1) = " << str3 << std::endl;
    std::strcat(str3, str2);
    std::cout << "strcat(str3, str2) = " << str3 << std::endl;

    return 0;
}